local thbattle__huoqinge_tongling = fk.CreateSkill {

  name = "thbattle__huoqinge_tongling",

  tags = { Skill.Limited, },

}



thbattle__huoqinge_tongling:addEffect(fk.Death, {
  anim_type = "big",
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(thbattle__huoqinge_tongling.name) 
    and player:usedSkillTimes(thbattle__huoqinge_tongling.name, Player.HistoryGame) == 0
    and player.phase~=Player.NotActive
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, thbattle__huoqinge_tongling.name, nil, "#thbattle__huoqinge_tongling:" .. target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local p = target
    room:doIndicate(player, { p })
    local skills = {}
    --加载技能
    for _, skill in ipairs(p.player_skills) do
      if not (skill.skeleton.attached_equip or skill.name[#skill.name] == "&") and
          (#skill.skeleton.attached_kingdom == 0 or table.contains(skill.skeleton.attached_kingdom, player.kingdom)) and
          (not table.contains(skill.skeleton.tags,Skill.Wake)  or not table.contains(skill.skeleton.tags,Skill.Limited)  
          or not table.contains(skill.skeleton.tags,Skill.Quest)) then
        table.insertIfNeed(skills, skill.name)
      end
    end
    if #skills > 0 then
      local choices
      local result = player.room:askForCustomDialog(player, thbattle__huoqinge_tongling.name,
        "packages/utility/qml/ChooseGeneralSkillsBox.qml", {
          { p.general }, { skills }, 1, 1, "#thbattle__huoqinge_tongling-choice", false
        })
      if result ~= "" then
        choices = result
      end
      if choices~=nil then
        room:handleAddLoseSkills(player, table.concat(choices, "|"), nil)
      end
    end
  end,
})

return thbattle__huoqinge_tongling